<?php

/**
 * Description of sitedef
 *
 * @author MohdaDev
 */

class sitedef {
        /**
	 * 
	 * @var string
	 * @access private
	 */
        private static $bdd_serv = null;
        
        /**
	 * 
	 * @var string
	 * @access private
	 */
        private static $bdd_port = null;

        /**
	 *
	 * @var string
	 * @access private
	 */
        private static $bdd_name = null;

        /**
	 *
	 * @var string
	 * @access private
	 */
        private static $bdd_user = null;

        /**
	 *
	 * @var string
	 * @access private
	 */
        private static $bdd_pwd = null;

        /**
	 *
	 * @var bool
	 * @access private
	 */
        private static $dev_status = null;

        /**
	 *
	 * @var array
	 * @access private
	 */
        private static $forbid_value = array("id");

        /**
	 *
	 * @var string
	 * @access private
	 */
        private static $dev_text = "Texte a saisir : ";

        /**
	 *
	 * @var db
	 * @access private
	 */
        private static $db = null;

    /**
     *
     * @access public
     */
    public static function init()
    {
        switch(self::get_server_name())
        {
            case "127.0.0.1":
                self::$bdd_serv = "localhost";
                self::$bdd_port = "80";
                self::$bdd_name = "federation";
                self::$bdd_user = "root";
                self::$bdd_pwd = "";
                self::$dev_status = false;
                break;
            default:
                self::$bdd_serv = "localhost";
                self::$bdd_port = "80";
                self::$bdd_name = "federation";
                self::$bdd_user = "root";
                self::$bdd_pwd = "";
                self::$dev_status = true;
                break;
        }
        self::$db = db::Get_instance();
        session_start();
    }

    /**
     * @access public
     * @return string bdd_name
     */
    public static function Get_bdd_name()
    {
        return self::$bdd_name;
    }

    /**
     * @access public
     * @return string bdd_serv
     */
    public static function Get_bdd_serv()
    {
        return self::$bdd_serv;
    }

    /**
     * @access public
     * @return string bdd_user
     */
    public static function Get_bdd_user()
    {
        return self::$bdd_user;
    }

    /**
     * @access public
     * @return string bdd_pwd
     */
    public static function Get_bdd_pass()
    {
        return self::$bdd_pwd;
    }

    /**
     * @access public
     * @return string forbid_value
     */
    public static function Get_forbid_value()
    {
        return self::$forbid_value;
    }

    /**
     * @access public
     * @return string dev_status
     */
    public static function Get_dev_status()
    {
        return self::$dev_status;
    }

    /**
     * @access public
     * @return string dev_text et la zone.
     */
    public static function Get_dev_text($zone)
    {
        return self::$dev_text.$zone;
    }

    /**
     * @access public
     * @return string Nom du serveur
     */
    public static function Get_server_name()
    {
        return $_SERVER["SERVER_NAME"];
    }

    /**
     * @access public
     * @return db $db
     */
    public static function GetBddConnection()
    {
        return self::$db;
    }

    public static function Redirection($url)
    {
        if(self::get_dev_status()) echo "<input type='button' value='suite' onclick='window.location = ".$url."'/>";
        header("location: ".$url);
    }
}

//set_include_path(get_include_path().PATH_SEPARATOR.sitedef::get_serv_root());
function __autoload($className) {
    require_once "class/$className.class.php";
}

sitedef::init();
?>
